<?php

/**
 * main.php
 *
 * This file holds frontend configuration settings.
 */
$frontendConfigDir = dirname(__FILE__);

$params = require_once($frontendConfigDir . DIRECTORY_SEPARATOR . 'params.php');

// Setup some default path aliases. These alias may vary from projects.
Yii::setPathOfAlias('root', ROOT);
Yii::setPathOfAlias('common', ROOT . DIRECTORY_SEPARATOR . 'common');
Yii::setPathOfAlias('backend', ROOT . DIRECTORY_SEPARATOR . 'backend'. DIRECTORY_SEPARATOR . 'protected');
Yii::setPathOfAlias('www', ROOT . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'www');

$mainLocalFile = $frontendConfigDir . DIRECTORY_SEPARATOR . 'main-local.php';
$mainLocalConfiguration = file_exists($mainLocalFile) ? require($mainLocalFile) : array();

$mainEnvFile = $frontendConfigDir . DIRECTORY_SEPARATOR . 'main-env.php';
$mainEnvConfiguration = file_exists($mainEnvFile) ? require($mainEnvFile) : array();

return CMap::mergeArray(
                array(
            // @see http://www.yiiframework.com/doc/api/1.1/CApplication#basePath-detail
            'basePath' => $frontendConfigDir . DIRECTORY_SEPARATOR . '..',
            // set parameters
            'params' => $params,
            // preload components required before running applications
            // @see http://www.yiiframework.com/doc/api/1.1/CModule#preload-detail
            //'preload' => array('log', 'bootstrap'),
            'preload' => array('', ''),
            // @see http://www.yiiframework.com/doc/api/1.1/CApplication#language-detail
            'language' => 'en',
            // uncomment if a theme is used
            /* 'theme' => '', */
            // setup import paths aliases
            // @see http://www.yiiframework.com/doc/api/1.1/YiiBase#import-detail
            'import' => array(
                'common.components.*',
                'common.components.helpers.*',
                'common.models.*',
                'common.models.user.*',
                'application.components.*',
                'application.models.*',
            ),
            /* uncomment and set if required */
            // @see http://www.yiiframework.com/doc/api/1.1/CModule#setModules-detail
            /* 'modules' => array(), */
            'components' => array(
                'errorHandler' => array(
                    // @see http://www.yiiframework.com/doc/api/1.1/CErrorHandler#errorAction-detail
                    'errorAction' => 'site/error'
                ),
				'user' => array(
            // enable cookie-based authentication
					'allowAutoLogin' => true,
					'class' => 'WebUser'
				),
				 /* load bootstrap components */
				'bootstrap' => array(
					'class' => 'common.extensions.bootstrap.components.Bootstrap',
					'responsiveCss' => true,
				),
                'db' => $params['db.connect'],
                'urlManager' => array(
                    'urlFormat' => 'path',
                    'showScriptName' => false,
                    'urlSuffix' => '',
                    'rules' => $params['url.rules']
                ),
                'settings' => $params['settings'],
                'cache' => $params['cache.file'],
                /*'log' => array(
                    'class'=>'CLogRouter',
                    'routes'=>array(
                      array(
                        'class'=>'CWebLogRoute',  'levels'=>'trace, info, error, warning',
                      ),
                      array(
                        'class'=>'CFileLogRoute',  'levels'=>'trace, info, error, warning',
                      ),
                    )
                ),*/
                /* load bootstrap components */
                //'bootstrap' => array(
                //    'class' => 'common.extensions.bootstrap.components.Bootstrap',
                //    'coreCss' => false
                    //'responsiveCss' => false,
                //),
                'Paypal' => $params['Paypal']
            /* make sure you have your cache set correctly before uncommenting */
            /* 'cache' => $params['cache.core'], */
            /* 'contentCache' => $params['cache.content'] */
            ),
            //'modules' => array(
            //    'blog', 'user'
            //)
    ), CMap::mergeArray($mainEnvConfiguration, $mainLocalConfiguration)
);